package cn.openea.perpartner.meily.rabbit.controller;

import cn.openea.perpartner.common.core.web.controller.BaseController;
import cn.openea.perpartner.common.core.web.domain.AjaxResult;
import cn.openea.perpartner.meily.rabbit.domain.BusinessDto;
import cn.openea.perpartner.meily.rabbit.domain.DelayDto;
import cn.openea.perpartner.meily.rabbit.domain.GroupDto;
import cn.openea.perpartner.meily.rabbit.service.impl.PublisherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "RabbitMQ")
@RestController
@RequestMapping("/rabbit")
public class RabbitController extends BaseController {
    @Autowired
    private PublisherService publisher;
    @ApiOperation("发送消息")
    @PostMapping("/cycle/send")
    public AjaxResult sendMsg(@RequestBody DelayDto dto){

       return toAjax(publisher.execute(dto));
    }

    @ApiOperation("业务消息")
    @PostMapping("/business/send")
    public AjaxResult sendMsg(@RequestBody BusinessDto dto){

        return toAjax(publisher.execute(dto));
    }

    @ApiOperation("团购消息")
    @PostMapping("/group/send")
    public AjaxResult sendMsg(@RequestBody GroupDto dto){
        return toAjax(publisher.execute(dto));
    }
}
